from django.db import models


# Create your models here.


class Singer(models.Model):
    singer_id = models.AutoField(primary_key=True,  verbose_name="歌手编号")
    singer_name = models.CharField(max_length=20, verbose_name='歌手名字')
    signer_pinshou = models.CharField(max_length=20, verbose_name='歌手名字拼音首字母')
    singer_type = models.CharField(max_length=20, verbose_name='歌手国籍')
    singer_gender = models.CharField(max_length=1, verbose_name='歌手性别', help_text="m为男，f为女，n为空")
    singer_img_add = models.CharField(max_length=255, blank=True, null=True, verbose_name="歌手图片地址")

    def __str__(self):
        return self.singer_name

    class Meta:
        db_table = 'singer'
        verbose_name = "歌手库"
        verbose_name_plural = verbose_name


class Music(models.Model):
    music_id = models.AutoField(primary_key=True, verbose_name="音乐编号")
    music_name = models.CharField(max_length=20, verbose_name='音乐名字')
    music_pinshou = models.CharField(max_length=20, verbose_name='音乐名字拼音首字母')
    music_type = models.CharField(max_length=20, verbose_name='音乐类型')
    music_duration = models.CharField(max_length=5, verbose_name='音乐时长')
    music_language = models.CharField(max_length=20, null=True, blank=True, verbose_name='音乐语言')
    music_size = models.FloatField(verbose_name='音乐大小', help_text="以KB为单位")
    music_singer_name = models.CharField(max_length=20, verbose_name="音乐歌手姓名" )
    music_singer_detail = models.ForeignKey(Singer, related_name='singer_music', on_delete=models.CASCADE, verbose_name='音乐歌手详细信息')
    # music_singer_detail = models.ManyToManyField('Singer', related_name='singer_music', verbose_name='音乐歌手详细信息')
    music_file_add = models.CharField(max_length=256, verbose_name='音乐文件地址')
    music_ban_add = models.CharField(max_length=256, null=True, blank=True, verbose_name='音乐伴唱文件地址')
    music_count = models.IntegerField(verbose_name='音乐被点击的次数', default=0)
    # singer_rep_songs = models.ForeignKey(Singer, related_name='rep_music', verbose_name='歌手代表作',
    #                                      on_delete=models.CASCADE)

    def __str__(self):
        return self.music_name

    class Meta:
        db_table = 'music'
        verbose_name = "歌曲库"
        verbose_name_plural = verbose_name




